require(['grid', 'topBar', 'layout','date'], function () {

    var postData;

    $('#top').topBar({
        left: [{
            type: 'filter-more',
            dateType:'custom',
            search: function () {
            	 if(getPostData()){
	                   $('#grid').grid('setGridParam', {
                           page:1,
	                       datatype: "json",
	                       postData: postData
	                   }).trigger("reloadGrid");
          	   }
            },
            item: [
                {
                    text: '时间快捷',
                    name1: 'beginTime',
                    name2: 'endTime',
                    type: 'dateLine'
                }
            ]
        }], 
        right: [
            {
                text: '导出',
                type: 'export-btn',
                authority: '',
                item: [
                    {
                        text: 'Excel导出',
                        click: function () {
                        	exportFile('Excel');
                        }
                    },
                    {
                        text: 'PDF导出',
                        click: function () {
                        	exportFile('Pdf');
                        }
                    }
                ]
            }
        ]
    });

    $('body').layout();

    function exportFile(suffix){
    	if(getPostData()){                 		
    		var url = "/vmsStatus/exportVMSStatus"+suffix+".htm";
			$.exportFile(url,postData);
	    }
    }

    //获取左侧选择的节点信息
	function getPostData(){
        var rcx = commonFun.getTreeCheckNodeToArgs();
        if (rcx) {
            postData = $.extend(rcx, $("#top").parent().getValues());
        }
        return rcx;
	}

    $('#grid').grid({
    	url : "/vmsStatus/SearchVMSStatus.htm",
		multiselect:false,
		colModel:[
		    {name: "carId", label:"carId", key: true, hidden: true},
			{name: "licPltNo", label:"车牌号",width:60},
			{name: "lineName", label:"运营线路",width:80},
			{name: "organName", label:"所属机构",width:80},
			{name: "rcrdTime", label:"采集时间",width:80},
			{name: "eltMhyCtrlInEltCrt",  label:"电机控制器输入电流", align: "right",width:180},
			{name: "eltMhyCtrlInVtg",  label:"电机控制器输入电压", align: "right",width:180},
			{name: "eltMhyRtteSpd",  label:"电机转速", align: "right",width:80},
			{name: "drvRevupPedal",  label:"司机加速踏板", align: "right",width:120},
			{name: "drvBrakPedal", label:"司机制动踏板", align: "right",width:120},
			{name: "driveStmSt", label:"驱动系统状态", align: "right",width:120}
		]
    });
    
})
